/* eslint-disable prefer-rest-params */
/* eslint-disable func-style */
/* eslint-disable jsdoc/no-restricted-syntax */
/**
 * @browser
 */
// polyfill
if (!String.fromCodePoint) {
  (function (__Object) {
    const defineProperty = (function () {
      // IE 8 only supports `Object.defineProperty` on DOM elements
      let result;
      try {
        /**
         * @type {*}
         */
        const object = {};
        const $defineProperty = __Object.defineProperty;
        result = $defineProperty(object, object, object) && $defineProperty;
        // eslint-disable-next-line no-empty
      } catch {}
      return result;
    })();
    const stringFromCharCode = String.fromCharCode;
    const { floor } = Math;
    const fromCodePoint = function () {
      const MAX_SIZE = 0x4000;
      const codeUnits = [];
      let highSurrogate;
      let lowSurrogate;
      let index = -1;
      const { length } = arguments;
      if (!length) {
        return "";
      }
      let result = "";
      while (++index < length) {
        let codePoint = Number(arguments[index]);
        if (
          !Number.isFinite(codePoint) || // `NaN`, `+Infinity`, or `-Infinity`
          codePoint < 0 || // not a valid Unicode code point
          codePoint > 0x10ffff || // not a valid Unicode code point
          floor(codePoint) !== codePoint // not an integer
        ) {
          throw new RangeError(`Invalid code point: ${codePoint}`);
        }
        if (codePoint <= 0xffff) {
          // BMP code point
          codeUnits.push(codePoint);
        } else {
          // Astral code point; split in surrogate halves
          // http://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae
          codePoint -= 0x10000;
          highSurrogate = (codePoint >> 10) + 0xd800;
          lowSurrogate = (codePoint % 0x400) + 0xdc00;
          codeUnits.push(highSurrogate, lowSurrogate);
        }
        if (index + 1 === length || codeUnits.length > MAX_SIZE) {
          // eslint-disable-next-line prefer-spread
          result += stringFromCharCode.apply(null, codeUnits);
          codeUnits.length = 0;
        }
      }
      return result;
    };
    if (defineProperty) {
      defineProperty(String, "fromCodePoint", {
        value: fromCodePoint,
        configurable: true,
        writable: true,
      });
    } else {
      String.fromCodePoint = fromCodePoint;
    }
  })(Object);
}

// effect
for (let j = "A".charCodeAt(0); j <= "Z".charCodeAt(0); j++) {
  const s = String.fromCodePoint(j);
  for (let i = 0; i < 0x10ffff; i++) {
    const e = String.fromCodePoint(i);
    if (s === e.toUpperCase() && s !== e) {
      // document.write("char: " + e + "<br/>");
      console.log(`char: ${e}`);
    }
  }
}
